/**
 * 项目名：五位一体化工安全信息平台
 * 日期：    2019-11-24 23:34:52
 * Copyright (c) 2015- joysuch-版权所有
 */
package com.joysuch.wwyt.bp.repository;

import com.joysuch.wwyt.bp.entity.BpJob;
import com.joysuch.wwyt.bp.entity.BpWorkType;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;

import java.util.List;


/**
 * BpWorkTypeDao
 */
public interface BpWorkTypeDao extends JpaRepository<BpWorkType, Long>, QuerydslPredicateExecutor<BpWorkType> {
    public Page<BpWorkType> findAll(Specification<BpWorkType> spec, Pageable pageable);

    public BpWorkType save(BpWorkType bean);

    public void delete(BpWorkType bean);

    int countByName(String name);

    @Query(value = "select * from wwyt_bp_work_type   where tenent_id = ?1 and delete_flag='0' ", nativeQuery = true)
    List<BpWorkType> findAllByTenentId(Long tenentId);

    @Query(value = "select * from wwyt_bp_work_type   where NAME = ?1 and delete_flag='0' limit 1", nativeQuery = true)
    BpWorkType findByName(String name);
}
